package com.zxc.xxljob.job;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.print.attribute.standard.JobHoldUntil;
import java.util.ArrayList;
import java.util.List;

@Component
public class helloJob {

    @Value("${server.port}")
    String port;

    @XxlJob("shardingJobHandler")
    public void JobTest() {

        int shardIndex = XxlJobHelper.getShardIndex();
        int shardTotal = XxlJobHelper.getShardTotal();
        List<Integer> integers=getList();

        for (Integer integer : integers) {
            if(integer%shardTotal==shardIndex){

                System.out.println("============:" + integer);
            }

        }
    }

    private List<Integer> getList() {

        ArrayList<Integer> integers = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            integers.add(i);
        }
        return integers;
    }


}
